
import { ADD, MINUS } from './constant'

const initState = 0
function countRedux(preState = initState, action) {
    // 从action对象中获取type，data
    const { type, data } = action
    // 根据type决定如何加工数据
    switch (type) {
        case ADD:
            return preState + data
        case MINUS:
            return preState - data
        default:
            return preState
    }
}
export default countRedux